package com.springboot.jktj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.springboot.common.annotation.Log;
import com.springboot.common.core.controller.BaseController;
import com.springboot.common.core.domain.AjaxResult;
import com.springboot.common.enums.BusinessType;
import com.springboot.jktj.domain.JktjCheckgroup;
import com.springboot.jktj.service.IJktjCheckgroupService;
import com.springboot.common.utils.poi.ExcelUtil;
import com.springboot.common.core.page.TableDataInfo;

/**
 * 套餐项目Controller
 * 
 * @author springboot
 * @date 2023-11-27
 */
@RestController
@RequestMapping("/jktj/checkgroup")
public class JktjCheckgroupController extends BaseController
{
    @Autowired
    private IJktjCheckgroupService jktjCheckgroupService;

    /**
     * 查询套餐项目列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(JktjCheckgroup jktjCheckgroup)
    {
        startPage();
        List<JktjCheckgroup> list = jktjCheckgroupService.selectJktjCheckgroupList(jktjCheckgroup);
        return getDataTable(list);
    }

    /**
     * 导出套餐项目列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:export')")
    @Log(title = "套餐项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JktjCheckgroup jktjCheckgroup)
    {
        List<JktjCheckgroup> list = jktjCheckgroupService.selectJktjCheckgroupList(jktjCheckgroup);
        ExcelUtil<JktjCheckgroup> util = new ExcelUtil<JktjCheckgroup>(JktjCheckgroup.class);
        util.exportExcel(response, list, "套餐项目数据");
    }

    /**
     * 获取套餐项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jktjCheckgroupService.selectJktjCheckgroupById(id));
    }

    /**
     * 新增套餐项目
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:add')")
    @Log(title = "套餐项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JktjCheckgroup jktjCheckgroup)
    {
        return toAjax(jktjCheckgroupService.insertJktjCheckgroup(jktjCheckgroup));
    }

    /**
     * 修改套餐项目
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:edit')")
    @Log(title = "套餐项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JktjCheckgroup jktjCheckgroup)
    {
        return toAjax(jktjCheckgroupService.updateJktjCheckgroup(jktjCheckgroup));
    }

    /**
     * 删除套餐项目
     */
    @PreAuthorize("@ss.hasPermi('jktj:checkgroup:remove')")
    @Log(title = "套餐项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jktjCheckgroupService.deleteJktjCheckgroupByIds(ids));
    }
}
